<html xmlns="http://www.w3.org/1999/xhtml"  
     xmlns:h="http://java.sun.com/jsf/html"      
     xmlns:f="http://java.sun.com/jsf/core"
     xmlns:ui="http://java.sun.com/jsf/facelets"
     xmlns:r="http://ricchieri.com/facelets"
     xmlns:p="http://primefaces.org/ui">  
 <h:head></h:head>  
 <h:body>
 	<ui:composition template="../../templates/commonLayoutReservation.xhtml">
 	<ui:define name="title">#{msg.titleReservation}</ui:define>
		<ui:define name="content">
		
		     <h:form id="searchReservationForm">
	     		<h:messages style="color:red;margin:8px;" />      
	     		<h2>#{msg.searchReservation}</h2> 
		     	<h:panelGrid columns="2">
		     		<h:panelGrid columns="2">
			     		<h:outputLabel for="reservationNumber" value="#{msg.reservationNumber}" />
			     		<p:inputText id="reservationNumber" value="#{searchReservationMB.reservationFilter.reservationId}" onkeypress="if(event.which &lt; 48 || event.which &gt; 57) return false;"/>
			     		
			     		<h:outputLabel for="firstName" value="#{msg.first_name}" />
			     		<p:inputText id="firstName" value="#{searchReservationMB.reservationFilter.firstName}"/>
			     		
			     		<h:outputLabel for="lastName" value="#{msg.last_name}" />  
					    <p:inputText id="lastName" value="#{searchReservationMB.reservationFilter.lastName}" />
			            
			            <h:outputLabel for="documentType" value="#{msg.documentType}"/>
			     		<p:selectOneMenu id="documentType" value="#{searchReservationMB.reservationFilter.documentType}">
			     			<f:selectItem itemLabel="#{msg.defaultComboValue}" itemValue="" />
			                <f:selectItems value="#{searchReservationMB.documentType}" />   
			            </p:selectOneMenu> 
			            
			     		<h:outputLabel for="dni" value="#{msg.documentNum}" />
					    <p:inputText id="dni" value="#{searchReservationMB.reservationFilter.dni}" onkeypress="if(event.which &lt; 48 || event.which &gt; 57) return false;"/>
					</h:panelGrid>    
					<h:panelGrid columns="2">
						<h:outputLabel value="#{msg.reservationStatus}" />
						<p:selectOneMenu value="#{searchReservationMB.reservationFilter.cancel}">
							<f:selectItem itemLabel="#{msg.defaultComboValue}" itemValue="" />
							<f:selectItems value="#{searchReservationMB.reservationStatus}" />
						</p:selectOneMenu>
					
					    <h:outputLabel value="#{msg.tripOrientation}" />
						<p:selectOneMenu value="#{searchReservationMB.reservationFilter.trip}">
							<f:selectItem itemLabel="#{msg.defaultComboValue}" itemValue="" />
							<f:selectItems value="#{searchReservationMB.trips}" />
						</p:selectOneMenu>
						
						<h:outputLabel value="#{msg.reservationType}"/>
		       	 		<p:selectOneMenu value="#{searchReservationMB.reservationFilter.reservationType}">
		       	 			<f:selectItem itemLabel="#{msg.defaultComboValue}" itemValue="" />
							<f:selectItems value="#{searchReservationMB.reservationType}" />
						</p:selectOneMenu>
						
						<h:outputLabel value="#{msg.from}" />
						<p:calendar pattern="dd/MM/yyyy" showOn="button"
							readOnlyInputText="true"
							value="#{searchReservationMB.reservationFilter.start}">
							<f:convertDateTime pattern="dd/MM/yyyy" timeZone="GMT-3" />
						</p:calendar>
						
						<h:outputLabel value="#{msg.to}" />
						<p:calendar pattern="dd/MM/yyyy" showOn="button"
							readOnlyInputText="true"
							value="#{searchReservationMB.reservationFilter.finish}">
							<f:convertDateTime pattern="dd/MM/yyyy" timeZone="GMT-3" />
						</p:calendar>
		         	</h:panelGrid>
				</h:panelGrid>
				<h:panelGrid columns="2" style="margin-top:10px; text-align:center">
	     			<r:commandLinkCustom id="reset" action="#{searchReservationMB}" method="reset" icon="icon-eraser" message="#{msg.resetButton}"/>
     				<r:commandLinkCustom id="search" action="#{searchReservationMB}" method="search" icon="icon-search" message="#{msg.searchButton}"/>
	     	 	</h:panelGrid>
	     	 	
	     	 	
     	 		<p:blockUI block="reservationTable" trigger="reservationTable">  
			        #{msg.loading}<br />  
			        <p:graphicImage value="/images/ajax-loader.gif"/>  
			    </p:blockUI>
	     	 	<p:dataTable var="reservation" value="#{searchReservationMB.reservationLazyDataModel}" 
	     	 		style="padding-top:15px" paginator="true" lazy="true" id="reservationTable"
	     	 		rows="10"
	     	 		paginatorPosition="bottom" emptyMessage="#{msg.noRecordsFound}">
	 
	 				<p:column headerText="#{msg.reservationNumber}" style="width:7%" sortBy="#{id}"> 
	 					<h:outputText value="#{reservation.id}" />
	 				</p:column>
	 				
	        		<p:column headerText="#{msg.date}" style="width:20%" sortBy="#{sortTime}">  
		            	<h:outputText value="#{searchReservationMB.formatDate(reservation.scheduleCharter.schedule.date)}" /> 
		            	<r:space/><r:space/>    
		            	<h:outputText value="#{reservation.scheduleCharter.schedule.time}" />   
	        		</p:column>
	        		
	        		<p:column headerText="#{msg.tripOrientation}" style="width:20%" sortBy="#{sortTrip}">  
		            	<h:outputText value="#{reservation.scheduleCharter.trip.getFormatTrip()}" />   
	        		</p:column>  
	        		
	        		<p:column headerText="#{msg.reservationStatus}" style="width:20%" sortBy="#{cancel}">  
		            	<h:outputText value="#{searchReservationMB.getStatusDescription(reservation.cancel)}"/>   
	        		</p:column> 
	 				
	 		 		<p:column headerText="#{msg.full_name}" style="width:30%" sortBy="#{sortFullname}">  
		            	<h:outputText value="#{reservation.user.getFullName()}"/>   
	        		</p:column> 
	 
	 				<p:column headerText="#{msg.documentType}" style="width:7%" sortBy="#{sortDocumentType}">  
		            	<h:outputText value="#{searchReservationMB.obtainDescription(reservation.user.documentType.description)}" />   
	        		</p:column> 
	        		
			        <p:column headerText="#{msg.documentNum}" style="width:20%" sortBy="#{sortDni}">  
		            	<h:outputText value="#{reservation.user.dni}" />   
	        		</p:column> 
	        		<p:column headerText="#{msg.actions}" style="width:40%">
	        			<center>
	        				<h:commandLink action="#{searchReservationMB.viewReservation(reservation)}" ajax="false" process="@form">
	        					<i class="icon-zoom-in icon-2x color-zoom"></i>
	        				</h:commandLink>
	        				<r:space/><r:space/>
	        				
	        				<h:commandLink action="#{searchReservationMB.editReservation(reservation)}" ajax="false" process="@form" rendered="#{!reservation.isTraveled()}">
	        					<i class="icon-edit icon-2x color-edit"></i>
	        				</h:commandLink>
	        				<r:space/><r:space/>
	        				
	        				<h:commandLink  action="#{searchReservationMB.cancelReservation(reservation)}" ajax="false" process="@form" rendered="#{!reservation.cancel}">
			       				<i class="icon-remove-sign icon-2x color-delete"></i>
		        			</h:commandLink>
	        			</center>
	        		</p:column>
	        		
	        	</p:dataTable>
		     	 	
		     </h:form> 
    	 </ui:define>
     </ui:composition>    
</h:body>
</html> 